home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / moonstonemadness.swf / scripts / __Packages / SideScroller / BasicObject.as < prev    next >
Encoding:
Text File  |  2007-09-27  |  4.3 KB  |  165 lines

  1. class SideScroller.BasicObject extends Library.State
  2. {
  3.    var oLayer;
  4.    var bObjectBlock;
  5.    var bObjectSpecial;
  6.    var mcRef;
  7.    var oGround;
  8.    var oNegativeGround;
  9.    var oPreCalculatedCoords;
  10.    var tmpCoord;
  11.    var nHitDistance;
  12.    function BasicObject(__mcRef, __oLayer)
  13.    {
  14.       super(__mcRef);
  15.       this.oLayer = __oLayer;
  16.       this.bObjectBlock = true;
  17.       this.bObjectSpecial = false;
  18.       this.oLayer.doAddObject(this);
  19.       if(this.mcRef.mcGround != undefined)
  20.       {
  21.          this.oGround = new SideScroller.Ground(this.mcRef.mcGround,this);
  22.       }
  23.       else if(this.mcRef.mcNegativeGround != undefined)
  24.       {
  25.          this.oNegativeGround = new SideScroller.NegativeGround(this.mcRef.mcNegativeGround,this);
  26.       }
  27.       this.setState("Idle");
  28.    }
  29.    function doEnterFrame()
  30.    {
  31.       super.doEnterFrame();
  32.       delete this.oPreCalculatedCoords;
  33.    }
  34.    function doCheckObjects()
  35.    {
  36.       var _loc3_ = this.oLayer.getSpecialObjects(this);
  37.       var _loc5_ = this.oLayer.Ref._x;
  38.       var _loc6_ = this.oLayer.Ref._y;
  39.       var _loc4_ = false;
  40.       var _loc2_ = undefined;
  41.       _loc2_ = 0;
  42.       while(_loc2_ <= _loc3_.length - 1)
  43.       {
  44.          if(_loc3_[_loc2_].Hit.hitTest(this.Hit))
  45.          {
  46.             this.onHitSpecial(_loc3_[_loc2_]);
  47.             _loc3_[_loc2_].onHitSpecial(this);
  48.          }
  49.          _loc2_ = _loc2_ + 1;
  50.       }
  51.    }
  52.    function doDestroy()
  53.    {
  54.       this.oGround.doDestroy();
  55.       this.oNegativeGround.doDestroy();
  56.       delete this.oGround;
  57.       delete this.oNegativeGround;
  58.       delete this.oPreCalculatedCoords;
  59.       delete this.tmpCoord;
  60.       this.mcRef.swapDepths(this.oLayer.getRemoveDepth(this.mcRef));
  61.       this.mcRef.removeMovieClip();
  62.       delete this.mcRef;
  63.       this.oLayer.doRemoveObject(this);
  64.       delete this.oLayer;
  65.    }
  66.    function onHit(__oRef)
  67.    {
  68.    }
  69.    function onHitSpecial(__oRef)
  70.    {
  71.    }
  72.    function get GroundObject()
  73.    {
  74.       if(this.oGround != undefined)
  75.       {
  76.          return this.oGround;
  77.       }
  78.       if(this.oNegativeGround != undefined)
  79.       {
  80.          return this.oNegativeGround;
  81.       }
  82.    }
  83.    function get GroundModifier()
  84.    {
  85.       return this.oGround != undefined || this.oNegativeGround != undefined;
  86.    }
  87.    function get ParentLayer()
  88.    {
  89.       return this.oLayer;
  90.    }
  91.    function get ObjectBlock()
  92.    {
  93.       return this.bObjectBlock;
  94.    }
  95.    function get ObjectSpecial()
  96.    {
  97.       return this.bObjectSpecial;
  98.    }
  99.    function get Hitable()
  100.    {
  101.       return this.mcRef.mcState.mcHit != undefined;
  102.    }
  103.    function get HitDistance()
  104.    {
  105.       return this.nHitDistance;
  106.    }
  107.    function get Hit()
  108.    {
  109.       return this.Ref.mcState.mcHit;
  110.    }
  111.    function get Coord()
  112.    {
  113.       if(this.oPreCalculatedCoords == undefined)
  114.       {
  115.          var _loc2_ = new Object();
  116.          if(this.OnLayerBaseLevel)
  117.          {
  118.             _loc2_.x = this.Ref._x;
  119.             _loc2_.y = this.Ref._y;
  120.          }
  121.          else
  122.          {
  123.             var _loc3_ = Library.Utils.MoreMath.getBoundsCenter(this.mcRef.getBounds(this.ParentLayer.Ref));
  124.             _loc2_.x = _loc3_.x;
  125.             _loc2_.y = _loc3_.y;
  126.          }
  127.          this.oPreCalculatedCoords = _loc2_;
  128.       }
  129.       return this.oPreCalculatedCoords;
  130.    }
  131.    function get OnLayerBaseLevel()
  132.    {
  133.       return this.mcRef._parent == this.ParentLayer.Ref;
  134.    }
  135.    function get Ref()
  136.    {
  137.       return this.mcRef;
  138.    }
  139.    function doLoadStateAction()
  140.    {
  141.       this.doCheckHitZone();
  142.    }
  143.    function doCheckHitZone()
  144.    {
  145.       var _loc4_ = undefined;
  146.       if(this.mcRef.mcState.mcHit != undefined)
  147.       {
  148.          _loc4_ = this.mcRef.mcState.mcHit;
  149.          this.mcRef.mcState.mcHit._visible = false;
  150.       }
  151.       else
  152.       {
  153.          _loc4_ = this.mcRef.mcState;
  154.       }
  155.       var _loc2_ = _loc4_.getBounds(this.mcRef);
  156.       var _loc5_ = Library.Utils.MoreMath.getDistance(0,0,_loc2_.xMin,_loc2_.yMin);
  157.       var _loc6_ = Library.Utils.MoreMath.getDistance(0,0,_loc2_.xMax,_loc2_.yMin);
  158.       var _loc7_ = Library.Utils.MoreMath.getDistance(0,0,_loc2_.xMix,_loc2_.yMax);
  159.       var _loc8_ = Library.Utils.MoreMath.getDistance(0,0,_loc2_.xMax,_loc2_.yMax);
  160.       var _loc3_ = Math.max(_loc5_,_loc6_,_loc7_,_loc8_);
  161.       _loc3_ = Math.abs(_loc3_);
  162.       this.nHitDistance = _loc3_;
  163.    }
  164. }
  165.